#!/bin/bash

if [ $# -ne 1 ]; then
   echo "Usage: $0 ip_address"
   exit 1;
fi

#ifconfig_out=`ifconfig eth1`
#mac_addr=`echo ${ifconfig_out} | awk '{ print $5 }'`
#echo "MAC Address of eth1 is $mac_addr"

echo "shuting down eth0  interface"

ifdown eth0
#ifdown lo

#iwconfig eth1 mode Ad-hoc essid maodv channel 1 enc off rts off

#iwconfig with power control
iwconfig eth1 mode Ad-hoc essid maodv channel 1 enc off rts off txpower -6 sens 30

ifconfig eth1 $1  netmask 255.255.255.0 broadcast 192.168.0.255 allmulti promisc
ip route del 224.0.0.0/4
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth1
echo 1 > /proc/sys/net/ipv4/ip_forward

#force IGMP v2
echo 2 > /proc/sys/net/ipv4/conf/eth1/force_igmp_version
echo 2 > /proc/sys/net/ipv4/conf/all/force_igmp_version

#echo "To test multicast, run ping -c 2 224.0.0.1"
